<?php $this->load->view('common/head');?>
<style type="text/css">
  .container{width: 100%;}
</style>
<form class="form-horizontal" name="add" id="add" action="<?php echo $this->input->server('REQUEST_URI'); ?>" method="post">
  <input type="hidden" name="id" id="id" value="<?=isset($detailData) ? $detailData['id'] : ''?>">
  <input type="hidden" name="procId" id="procId" value="<?=$procId?>">
  <input type="hidden" name="projectId" id="projectId" value="<?=$projectId?>">
  <input type="hidden" name="offlineId" id="offlineId" value="<?=$offlineId?>">
  <table class="table table-bordered">
    <thead>
      <tr>
        <th class="bg-primary">类型</th>
        <th class="bg-primary">费用项目描述</th>
        <th class="bg-primary">活动开始时间</th>
        <th class="bg-primary">活动结束时间</th>
        <th class="bg-primary">预算费用</th>
        <th class="bg-primary">备注</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>
        	<select required class="form-control" style="width: 130px;" placeholder="" id="type" name="type">
        		<option value="">请选择</option>
	        </select>
        </td>
        <td>
        	<select required class="form-control" style="width: 110px;" placeholder="" id="descType" name="descType">
        	<option value="">请选择</option>
	        </select>
	        <input type="input" class="form-control" name="descTypeAlias" id="descTypeAlias" value="<?=isset($detailData) ? $detailData['descTypeAlias'] : ''?>" placeholder="其它费用项目描述">
        </td>
        <td>
    		   	<input type="input" required class="form-control" style="width: 100px;" onFocus="WdatePicker({minDate:'<?=$offlineData['startTime']?>',maxDate:'#F{$dp.$D(\'endTime\')||\'<?=$offlineData['endTime']?>\'}'})" name="startTime" id="startTime" value="<?=isset($detailData) ? $detailData['startTime'] : ''?>" placeholder="开始时间">
    		</td>
    		<td>
    		   	<input type="input" required class="form-control" style="width: 100px;" onFocus="WdatePicker({minDate:'#F{$dp.$D(\'startTime\')||\'<?=$offlineData['startTime']?>\'}',maxDate:'<?=$offlineData['endTime']?>'})" name="endTime" id="endTime" value="<?=isset($detailData) ? $detailData['endTime'] : ''?>" placeholder="结束时间">
        </td>
        <td>
        	<input type="number" required min="0" step="0.01" class="form-control"  style="width: 100px;" name="budgetApply" id="budgetApply" value="<?=(float)$detailData['budgetApply'] ? $detailData['budgetApply'] : ''?>" placeholder="预算费用">
        </td>
        <td>
        	<textarea class="form-control" name="remarks" id="remarks" rows="3"><?=isset($detailData) ? $detailData['remarks'] : ''?></textarea>
        </td>
      </tr>
    </tbody>
  </table>
  <div class="form-group">
	<div class="text-center">
	  <button type="submit" class="btn btn-default btn-primary">保存</button>
	  <button type="button" onclick="closeWindow()" class="btn btn-default btn-primary">取消</button>
  	</div>
	  </div>
</form>
<script type="text/javascript" src="public/js/commonOffline.js"></script>
<script type="text/javascript">
$(function(){
  initValidation();
	offlineDetailTypeDisplay('type', <?=isset($detailData) ? $detailData['type'] : 0?>);
	descTypeDisplay(<?=isset($detailData) ? $detailData['type'] : 0?>,<?=isset($detailData) ? $detailData['descType'] : 0?>);
	descTypeAliasDisplay(<?=isset($detailData) ? $detailData['descType'] : ''?>);
	$("#type").change(function(){
		descTypeDisplay(this.value);
    descTypeAliasDisplay();
    initValidation();
	});
	$("#descType").change(function(){
		descTypeAliasDisplay(this.value);
    initValidation();
	});
});
//初始化验证
function initValidation(){
  $('form[name="add"]').find("input,select,textarea").jqBootstrapValidation("destroy");
  $('form[name="add"]').find("input,select,textarea").not("[type=submit]").jqBootstrapValidation({
      preventSubmit:false,
      submitSuccess: function (form, event) {
           event.preventDefault();
           ajaxFormSubmit('add');
       },
       submitError: function (form, event, errors) {
         event.preventDefault();
         }
    });
}
</script>
<?php $this->load->view('common/foot');?>